package org.hgvc.webapp.ets.jsf.beans.partner;

import java.util.Date;
import java.util.List;

import org.hgvc.webapp.ets.bo.Partner;
import org.hgvc.webapp.ets.bo.PartnerProductBooking;
import org.hgvc.webapp.ets.spring.service.PartnerService;
import org.jocsb.base.AbstractBean;
import org.jocsb.base.exception.BaseException;
import org.jocsb.base.util.FacesUtils;


public class PartnerBookingBean extends AbstractBean {
	
	public static final String BEAN_NAME="partnerBookingBean";
	public static final String NAV_LIST="partnerBookingCheckList";
	public List<PartnerProductBooking> bookingList;
	public PartnerService service;
	private Date from;
	private Date to;
	private Partner partner;
	public Date getTo() {
		return to;
	}
	public void setTo(Date to) {
		this.to = to;
	}
	public Date getFrom() {
		return from;
	}
	public void setService(PartnerService service) {
		this.service = service;
	}
	
	
	/*------------------------------------------------------------------------------------------*/
	public List<PartnerProductBooking> getBookingList() {
		if(partner==null){
			PartnerBean bean = (PartnerBean)FacesUtils.getManagedBean(PartnerBean.BEAN_NAME);
			partner = bean.getPartner();
		}
		try{
			bookingList = service.getPartnerProductBookingList(from, to, partner.getPartnerId());
		}catch(BaseException be){
			be.printStackTrace();
			initErrorBean(be);
		}
		return bookingList;
	}
	
	public String navListAction(){
		return NAV_LIST;
	}
	
	public String searchAction(){
		return NAV_LIST;
	}
	
	public String navBackAction(){
		return PartnerBean.NAV_PARTNER_PORTAL;
	}
}
